﻿
var providers;

$('#ProviderListPage').bind('pageinit', function(event) {
	if (sessionStorage.getItem('theName') != '' )
	    {
		     getProviderList();
	    }
});

function getProviderList() {

     var theName = sessionStorage.getItem('theName');
	 var thePass = sessionStorage.getItem('thePass');
	 
    console.log(URLserviceProviders + '/getproviders.php?name='+theName+'&thePass='+thePass);
	
	$.getJSON(URLserviceProviders + '/getproviders.php?name='+theName+'&thePass='+thePass, function(data) {
		$('#ProviderList li').remove();
		providers = data.items;

		$.each(providers, function(index, providers) {
			$('#ProviderList').append('<li><a href="#detailsProviderPage?id=' + providers.id + '">' +
					'<h4>' + providers.name + ' ' + providers.city + '</h4>');
		});
		$('#ProviderList').listview('refresh');
	});
	
}
